import sys
import cost_distance

if __name__ == "__main__":
    argv = sys.argv

    input_shp = None
    cost_tif = None
    out_file = None

    i = 1
    while i < len(argv):
        arg = argv[i]

        if arg == '-o' or arg == '-out':
            i = i + 1
            out_file = argv[i]

        elif input_shp is None:
            input_shp = argv[i]

        elif cost_tif is None:
            cost_tif = argv[i]

        else:
            print('must have at least two arguments: input.shp cost.tif')
            sys.exit(1)

        i = i + 1

    if out_file is not None:
        cost_distance.main(input_shp, cost_tif, out_file)
    else:
        cost_distance.main(input_shp, cost_tif)